package com.surfacing.rcp.model.entity;

import java.sql.Date;
import java.sql.Timestamp;

import com.surfacing.rcp.model.common.AbstractMessage;

public class Journal extends AbstractMessage {
	// unique identification string
	public final static String ID = "Journal";

	// j.protokollnummer, j.datum, j.name, tpz.transportziel, j.alarmZeit,
	// j.endZeit, j.notfallort, j.nachforderung, ea.einsatzart, ds.dienststelle,
	// j.azubi, CONCAT(n.firstName,''n.lastName) AS NFS,
	// CONCAT(n.firstName,''n.lastName) AS Arzt, j.naca, j.km
	private int id;
	private String protokollnummer;
	private Date datum;
	private String name;
	private Transportziel transportziel;
	private long alarmZeit;
	private long endZeit;
	private String notfallort;
	private Anforderung nachforderung;
	private Einsatzart einsatzart;
	private Dienststelle dienststelle;
	private String azubi;
	private Nfs nfs;
	private Doctor doctor;
	private Naca naca;
	private String km;
	private Timestamp created;
	private Timestamp changed;

	/**
	 * Class constructor for a staff member
	 */
	public Journal() {
		super(ID);
		// set default values
		id = -1;
	}

	/**
	 * Class constructor for a complete staff member
	 */
	// INSERT INTO Journal(protokollnummer, datum, name, alarmZeit,
	// endZeit,
	// notfallort, nachforderung, transportziel_fk, einsatzart_fk,
	// dienststelle_fk, azubi, nfs_fk, doctor_fk, km, naca)
	public Journal(int id, String protokollnummer, Date datum, String name,
			long alarmZeit, long endZeit, String notfallort,
			Anforderung nachforderung, Transportziel transportziel,
			Einsatzart einsatzart, Dienststelle dienststelle, String azubi,
			Nfs nfs, Doctor doctor, String km, Naca naca) {
		this();
		setId(id);
		setProtokollnummer(protokollnummer);
		setDatum(datum);
		setName(name);
		setAlarmZeit(alarmZeit);
		setEndZeit(endZeit);
		setNotfallort(notfallort);
		setNachforderung(nachforderung);
		setTransportziel(transportziel);
		setEinsatzart(einsatzart);
		setDienststelle(dienststelle);
		setAzubi(azubi);
		setNfs(nfs);
		setDoctor(doctor);
		setKm(km);
		setNaca(naca);
	}

	/**
	 * Returns a string based description of the object
	 * 
	 * @return the description of the object
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("PKnr: ").append(protokollnummer).append(" - ").append("Date: ").append(datum).append(" - ")
				.append("NFS: ").append(nfs.toString()).append(" - ").append("Doc: ").append(doctor.toString())
				.append(" - ").append("DS: ").append(dienststelle).append(" - ")
				.append("Einsatzart: ").append(einsatzart).append(" - ").append("TPZ:").append(transportziel);
		return sb.toString();
	}

	/**
	 * Returns the calculated hash code based on the staff member id.<br>
	 * Two staff members have the same hash code if the id is the same.
	 * 
	 * @return the calculated hash code
	 */
	@Override
	public int hashCode() {
		return 31 + id;
	}

	/**
	 * Returns whether the objects are equal or not.<br>
	 * Two staff members are equal if, and only if, the id is the same.
	 * 
	 * @return true if the id is the same otherwise false.
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Journal other = (Journal) obj;
		if (id != other.id)
			return false;
		return true;
	}

	// SETTERS AND GETTERS
	/**
	 * Returns the personal identification number.
	 * 
	 * @return the staffMemberId
	 */
	public int getId() {
		return id;
	}

	/**
	 * Sets the personal identification number.
	 * 
	 * @param staffMemberId
	 *            the personId to set
	 * @throws IllegalArgumentException
	 *             if the id is negative
	 */
	public void setId(int id) {
		this.id = id;
	}

	public String getProtokollnummer() {
		return protokollnummer;
	}

	public void setProtokollnummer(String protokollnummer) {
		this.protokollnummer = protokollnummer;
	}

	public Date getDatum() {
		return datum;
	}

	public void setDatum(Date datum) {
		this.datum = datum;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		if (name == null || name.trim().isEmpty())
			throw new IllegalArgumentException(
					"The name cannot be null or empty");
		this.name = name;
	}

	public Transportziel getTransportziel() {
		return transportziel;
	}

	public void setTransportziel(Transportziel transportziel) {
		this.transportziel = transportziel;
	}

	public long getAlarmZeit() {
		return alarmZeit;
	}

	public void setAlarmZeit(long alarmZeit) {
		this.alarmZeit = alarmZeit;
	}

	public long getEndZeit() {
		return endZeit;
	}

	public void setEndZeit(long endZeit) {
		this.endZeit = endZeit;
	}

	public String getNotfallort() {
		return notfallort;
	}

	public void setNotfallort(String notfallort) {
		if (notfallort == null || notfallort.trim().isEmpty())
			throw new IllegalArgumentException(
					"The notfallort cannot be null or empty");
		this.notfallort = notfallort;
	}

	public Anforderung getNachforderung() {
		return nachforderung;
	}

	public void setNachforderung(Anforderung nachforderung) {
		this.nachforderung = nachforderung;
	}

	public Einsatzart getEinsatzart() {
		return einsatzart;
	}

	public void setEinsatzart(Einsatzart einsatzart) {
		this.einsatzart = einsatzart;
	}

	public Dienststelle getDienststelle() {
		return dienststelle;
	}

	public void setDienststelle(Dienststelle dienststelle) {
		this.dienststelle = dienststelle;
	}

	public String getAzubi() {
		return azubi;
	}

	public void setAzubi(String azubi) {
		if (azubi == null || azubi.trim().isEmpty())
			this.azubi = "";
		this.azubi = azubi;
	}

	public Nfs getNfs() {
		return nfs;
	}

	public void setNfs(Nfs nfs) {
		this.nfs = nfs;
	}

	public Doctor getDoctor() {
		return doctor;
	}

	public void setDoctor(Doctor doctor) {
		this.doctor = doctor;
	}

	public Naca getNaca() {
		return naca;
	}

	public void setNaca(Naca naca) {
		this.naca = naca;
	}

	public String getKm() {
		return km;
	}

	public void setKm(String km) {
		if (km == null || km.trim().isEmpty())
			throw new IllegalArgumentException("The km cannot be null or empty");
		this.km = km;
	}

	public Timestamp getCreated() {
		return created;
	}

	public void setCreated(Timestamp created) {
		this.created = created;
	}

	public Timestamp getChanged() {
		return changed;
	}

	public void setChanged(Timestamp changed) {
		this.changed = changed;
	}

}